package com.navinfo.platform.bigdata.dto;

import com.navinfo.platform.bigdata.util.EntityConvert;
import com.navinfo.stream.qingqi.protocol.java.LCAreaType;
import com.navinfo.stream.qingqi.protocol.java.LCLocationData.StaytimeParkingAddition;

public class StaytimeParkingAdditionDto {
    private String areaType;
    private long areaId;

    public String getAreaType() {
        return areaType;
    }
    public void setAreaType(String areaType) {
        this.areaType = areaType;
    }
    public long getAreaId() {
        return areaId;
    }
    public void setAreaId(long areaId) {
        this.areaId = areaId;
    }

    /**
     *  解析成String拼接字符串
     * @param staytimeParkingAddition
     * @return
     */
    public static String parseString(StaytimeParkingAddition staytimeParkingAddition){
        return EntityConvert.convert(
                staytimeParkingAddition.getAreaId(),
                staytimeParkingAddition.getAreaType().getNumber()
        );
    }

    /**
     * 反解析成PB对象
     * @param str
     * @return
     */
    public static StaytimeParkingAddition parsePB(String str){
        StaytimeParkingAddition.Builder builder = null;
        try{
            String[] revert = EntityConvert.revert(str);
            if(null!=revert && revert.length>=2){
                builder = StaytimeParkingAddition.newBuilder();
                builder.setAreaId(Long.valueOf(revert[0]));
                builder.setAreaType(LCAreaType.AreaType.valueOf(revert[1]));
            }
        }catch (Exception e){
            e.printStackTrace();
        }

        return builder==null? null : builder.build();
    }
}
